/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package events.animation;

import gui.SnazzySpritesGUI;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import snazzysprites.SnazzySprites;
import state.Animation;
import state.SnazzySpritesState;
import state.SnazzySpritesStateManager;

/**
 * Handles the deletion of the current animation
 * @author Andrew Gratta <andrew.gratta@stonybrook.edu>
 */
public class DeleteAnimationHandler implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        SnazzySprites singleton = SnazzySprites.getSnazzySprites();
        SnazzySpritesStateManager manager = singleton.getStateManager();
        SnazzySpritesGUI gui = singleton.getGUI();
        Animation anim = manager.getAnimation();
        if (anim != null)
        {
            manager.deselectPose();
            manager.deselectAnimation();
            manager.getSpriteType().deleteAnimation(anim.getName());
            manager.getSprite().clearPreview();
            gui.setAnimationComboBoxItems(manager.getAnimationNames());
            manager.markSpriteTypeChanged();
        }
    }
    
}
